from os.path import join, abspath
import json
from backend.experiment.clue.chid.scheme0.implement import CHIDImplement as S0

TEST_SAMPLES = 200


class CHIDImplement(S0):
    @classmethod
    def _read_dev_records(cls) -> list:
        with open(join(cls.data_dir(), 'dev.json'), 'r', encoding='utf8') \
                as file:
            records = [json.loads(each) for each in file.readlines()]
        return records[:TEST_SAMPLES]

    @classmethod
    def _read_test_records(cls) -> list:
        with open(join(cls.data_dir(), 'test.json'), 'r', encoding='utf8') \
                as file:
            records = [json.loads(each) for each in file.readlines()]
        return records[:TEST_SAMPLES]

    @classmethod
    def data_dir(cls) -> str:
        return abspath(join(__file__, '../..'))

    @classmethod
    def cache_dir(cls) -> str:
        return join(cls.work_dir(), 'cache')

    @classmethod
    def work_dir(cls) -> str:
        return abspath(join(__file__, '..'))
